package com.hopital5.zhangyz.controller;

import com.hopital5.zhangyz.service.ActivityService;
import com.hopital5.zhangyz.vo.request.ActivityVoRequest;
import com.hopital5.zhangyz.vo.response.ActivityVoResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/activity")
public class ActivityController extends BaseController {
    @Autowired
    ActivityService activityService;

    @PutMapping
    public ActivityVoResponse insert(@RequestBody ActivityVoRequest activityVoRequest) {
        return ActivityVoResponse.build(activityService.save(activityVoRequest));
    }

    @PostMapping
    public ActivityVoResponse update(@RequestBody ActivityVoRequest activityVoRequest) {
        return ActivityVoResponse.build(activityService.update(activityVoRequest));
    }

    @GetMapping("/{activityId}")
    public ActivityVoResponse detail(@PathVariable Long activityId) {
        return ActivityVoResponse.build(activityService.findOne(activityId));
    }
}
